/*
 * thrTable.h
 *
 *  Created on: Apr 30, 2011
 *      Author: xrose
 */

#ifndef THRTABLE_H_
#define THRTABLE_H_
#include "thrdStruct.h"
#include "incdefault.h"

class thrTable{
private:
	thrdStruct *_thrRec;
	uint _capacity;
	uint _size;
public:
	thrTable():_thrRec(),_capacity(0), _size(0){
		cout<<"DEBUG: ...thrTable::thrTable()::_thrRec.id = "<<_thrRec->getID()<<endl;
	};
	thrTable(int capacity):_capacity(capacity), _size(0){
		_thrRec = new thrdStruct[_capacity];
	}
	~thrTable(){
		delete [] _thrRec;
	}
	int insert(thrdStruct thrdRec){
		cout<<"DEBUG: ...thrTable::insert(thrStruct)"<<thrdRec.getStByte()<<endl;
		cout<<"DEBUG: ...thrTable::insert(thrStruct)"<<thrdRec.getEndByte()<<endl;
		if(_size == _capacity) return 1;
		int thrId = thrdRec.getID();
		_thrRec[thrId] = thrdStruct(thrdRec);
		_size++;
		return 0;
	}
	thrdStruct *getRecordHandle(uint thrId){
		cout<<"DEBUG: ...thrTable::getRecordHanle::thrId = "<<thrId<<endl;
		if(thrId >= _size) return NULL;
		return &_thrRec[thrId];
	}
	uint getCapacity(){
		return _capacity;
	}
	uint getSize(){
		return _size;
	}
};

#endif /* THRTABLE_H_ */
